﻿<script src="/static/js/jquery-2.1.1.js"></script>
<script src="/static/bootstrap/js/bootstrap.js"></script>
<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
<link href="/static/layui/css/layui.css" rel="stylesheet"/>
<script src="/static/layui/layui.js"></script>

<style>
    .layui-inline{margin-bottom:15px;display: inline-block}
    .layui-input-block{margin-left:0px!important;}
    .layui-table th{text-align: center}
    .title{width:150px;text-align: center}
    .layui-layer-demo{top:20px!important;}
    .layui-layer-dialog{top:180px!important;}
    .one{color: red}
    .show_view{position: relative}
    .show_view span{position: absolute;top:0px;font-size:10px;left:0px;background-color: red;color: #FFFFFF;padding:0px 6px}
</style>
<div class="modal-body">

    <!--layui-form-pane-->
    <form class="layui-form layui-form-pane form-horizontal" name="layui-form" action="" >


        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">年份</label>
            <div class="input-group col-xs-10" style="float: left">
                <input type="text" class="layui-input" name="year" id="test2" value="{$year}" >
            </div>
        </div>

        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">计划类别</label>
            <div class="input-group col-xs-10" style="float: left">
                <select lay-verify="plan_category" lay-filter="plan_category" class="select" >
                    <option value="0">请选择</option>
                    {volist name="plan_category" id="vo" }
                        <option value="{$key}" {if condition="$detail['plan_category'] eq $key"} selected {/if}>{$vo}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item layui-col-md12">
            <table class="layui-table">
                <thead>
                <tr>
                    <th class="title">项目推进计划</th>
                    {volist name="month" id="vo"}
                    <th>
                        {$vo.name}月
                    </th>
                    {/volist}
                </tr>
                </thead>

                <tbody>
                    {volist name="project_type" id="vo"}
                        <tr>
                            <td class="title one">{$vo.name}</td>
                            {volist name="$vo.month" id="vo1"}
                            <!---->
                            {if condition="$vo['childCount'] eq 0"}
                                <th class="show_view"  data-val="{$vo.id}" data-month="{$vo1.name}" style="background-color:{$vo1.police}">
                                    {if condition="$vo1['status'] eq 1"}
                                        {if condition="$vo1.declare_content eq 1"}
                                        <span>审</span>
                                        {/if}
                                        {if condition="$vo1.declare_schedule eq 0"}
                                            √
                                        {else/}
                                            {$vo1.declare_schedule}
                                        {/if}
                                    {/if}
                                </th>
                                {else}
                                <th data-val="{$vo.id}" data-month="{$vo1.name}" style="background-color:#f7f7f7">
                                    {if condition="$vo1.status eq 1"}
                                    √
                                    {/if}
                                    {if condition="$vo1.status eq 2"}
                                    ×
                                    {/if}
                                </th>
                            {/if}

                            {/volist}
                        </tr>
                        {volist name="vo.child" id="child"}
                            <tr>
                                <td class="title">{$child.name}</td>
                                {volist name="$child.month" id="childVo"}
                                <th class="show_view"  data-val="{$child.id}" data-month="{$childVo.name}" style="background-color:{$childVo.police}">
                                    {if condition="$childVo.status eq 1"}
                                        {if condition="$childVo.declare_content eq 1 & $childVo.declare_status==0"}
                                        <span>审</span>
                                        {/if}
                                        {if condition="$childVo.declare_schedule eq 0"}
                                            √
                                        {else/}
                                            {$childVo.declare_schedule}
                                        {/if}
                                    {/if}
                                </th>
                                {/volist}
                            </tr>
                        {/volist}


                    {/volist}

                </tbody>




            </table>
        </div>


</form>

</div>
<script>
    var id = "{$id}";  //项目id
    layui.use(['form','jquery','layer','laydate','table','upload'], function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer,upload = layui.upload;;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table //表格

        //更新项目计划类别
        form.on('select(plan_category)', function (data) {
            //触发联动
            var plan_id = data.value;
            $.ajax({
                type: 'post',
                url: "{:URL('project/communal/updatePlan')}",
                data: {id: id,plan_id:plan_id},
                dataType: 'JSON',
                success: function (res) {
                    location.reload();
                },
                error: function (res) {
                }
            });
        });


        $(".show_view").click(function () {
            var year = $("input[name='year']").val();
            var procedure = $(this).attr("data-val");  //流程id
            var month = $(this).attr("data-month");  //月份
            //打开添加视图
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                area: ['700px','720px'],            //宽度450px,高自适应
                anim: 2,
                shadeClose: false, //开启遮罩关闭,
                maxmin: true,
                title: "推进计划",
                content:"{:URL('project/Communal/addProcedure')}?procedure="+procedure+"&month="+month+"&id="+id+"&year="+year,
                btn:['确定','删除','取消'],
                yes: function (index,layero) {
                    var body = layer.getChildFrame('body', index);
                    var data = body.find("form[name='addProcedure']").serializeArray();
                    data.push({name: "pro_id", value: id});
                    data.push({name: "type_id", value: procedure});
                    data.push({name: "month", value: month});
                    data.push({name: "year", value: year});
                    $.ajax({
                        type: "post",
                        url: "{:URL('project/Communal/advanceDo')}",
                        data: data,
                        dataType: "json",
                        success: function (data) {
                            if(data.code!=0){
                                layer.alert(data.msg);
                            }else{
                                location.reload();
                                layer.close(index);
                            }
                        }
                    });
                },
                btn2:function(index,layero){
                    var data = {year:year,type_id:procedure,month:month,delete:"delete",pro_id:id};
                    $.ajax({
                        type: "post",
                        url: "{:URL('project/Communal/advanceDo')}",
                        data: data,
                        dataType: "json",
                        success: function (data) {
                            if(data.code!=0){
                                layer.alert(data.msg);
                            }else{
                                location.reload();
                                layer.close(index);
                            }
                        }
                    });


                }
            });

        });


        //年选择器
        laydate.render({
            elem: '#test2'
            ,type: 'year'
            ,done:function(value,data){
                window.location.replace("{:URL('project/Communal/advanceview')}?id="+id+"&year="+value);
            }
        });



        layui.form.render('select');
    });

</script>